suppressMessages(library(ArchR))
ss <- function(x, pattern, slot = 1, ...) { sapply(strsplit(x = x, split = pattern, ...), '[', slot) }
options(stringsAsFactors = F)
options(repr.plot.width=11, repr.plot.height=8.5)
##################################
### set Arrow File parameters ####
addArchRThreads(threads = 10)
##################################
### load rheMac10 ArchR genome ###
GENOMEDIR='/home/bnphan/resources/genomes/rheMac10'
load(file.path(GENOMEDIR,'rheMac10_liftoff_GRCh38.p13_ArchR_annotations.rda'))
Setting default number of Parallel threads to 10.
PROJDIR='../../../data/tidy_data/ArchRProjects'
ARCHDIR=file.path(PROJDIR,'ArchR_DLPFC_scATAC')
proj = loadArchRProject(ARCHDIR)
Successfully loaded ArchRProject!
/ |
/ \
. / |.
\\\ / |.
\\\ / `|.
\\\ / |.
\ / |\
\\#####\ / ||
==###########> / ||
\\##==......\ / ||
______ = =|__ /__ || \\\
,--' ,----`-,__ ___/' --,-`-===================##========>
\ ' ##_______ _____ ,--,__,=##,__ ///
, __== ___,-,__,--'#' ===' `-' | ##,-/
-,____,---' \\####\\________________,--\\_##,/
___ .______ ______ __ __ .______
/ \ | _ \ / || | | | | _ \
/ ^ \ | |_) | | ,----'| |__| | | |_) |
/ /_\ \ | / | | | __ | | /
/ _____ \ | |\ \\___ | `----.| | | | | |\ \\___.
/__/ \__\ | _| `._____| \______||__| |__| | _| `._____|
# plot the confusion matrix of cell types by subjects
cM <- confusionMatrix(paste0(proj$ClustersH200_ATAC), paste0(proj$Sample))
cM <- cM / Matrix::colSums(cM)
p <- pheatmap::pheatmap(
mat = as.matrix(cM),
color = paletteContinuous("whiteBlue"),
border_color = "black")
p
## make UMAP plots
p1 <- plotEmbedding(ArchRProj = proj, colorBy = "cellColData",
name = "ClustersH200_ATAC", embedding = "UMAPH200_ATAC")
p3 <- plotEmbedding(ArchRProj = proj, colorBy = "cellColData",
name = "Animal", embedding = "UMAPH200_ATAC")
ggAlignPlots(p1, p3, type = "h")
ArchR logging to : ArchRLogs/ArchR-plotEmbedding-41da24d4df6a-Date-2022-01-07_Time-08-43-28.log If there is an issue, please report to github with logFile! Getting UMAP Embedding ColorBy = cellColData Plotting Embedding 1 Length of unique values greater than palette, interpolating.. ArchR logging successful to : ArchRLogs/ArchR-plotEmbedding-41da24d4df6a-Date-2022-01-07_Time-08-43-28.log ArchR logging to : ArchRLogs/ArchR-plotEmbedding-41da140eef-Date-2022-01-07_Time-08-43-30.log If there is an issue, please report to github with logFile! Getting UMAP Embedding ColorBy = cellColData Plotting Embedding 1 ArchR logging successful to : ArchRLogs/ArchR-plotEmbedding-41da140eef-Date-2022-01-07_Time-08-43-30.log
## make UMAP plots of
p1 <- plotEmbedding(ArchRProj = proj, colorBy = "cellColData",
name = "ClustersH200_ATAC", embedding = "UMAPH200_ATAC")
p2 <- plotEmbedding(ArchRProj = proj, colorBy = "cellColData",
name = "DoubletEnrichment", embedding = "UMAPH200_ATAC")
ggAlignPlots(p1, p2, type = "h")
proj$logNFrags = log10(proj$nFrags)
p3 <- plotEmbedding(ArchRProj = proj, colorBy = "cellColData",
name = "logNFrags", embedding = "UMAPH200_ATAC")
ggAlignPlots(p1, p3, type = "h")
p4 <- plotEmbedding(ArchRProj = proj, colorBy = "cellColData",
name = "TSSEnrichment", embedding = "UMAPH200_ATAC")
ggAlignPlots(p1, p4, type = "h")
ArchR logging to : ArchRLogs/ArchR-plotEmbedding-41da211b1393-Date-2022-01-07_Time-08-43-40.log If there is an issue, please report to github with logFile! Getting UMAP Embedding ColorBy = cellColData Plotting Embedding 1 Length of unique values greater than palette, interpolating.. ArchR logging successful to : ArchRLogs/ArchR-plotEmbedding-41da211b1393-Date-2022-01-07_Time-08-43-40.log ArchR logging to : ArchRLogs/ArchR-plotEmbedding-41da76481ac9-Date-2022-01-07_Time-08-43-40.log If there is an issue, please report to github with logFile! Getting UMAP Embedding ColorBy = cellColData Plotting Embedding 1 ArchR logging successful to : ArchRLogs/ArchR-plotEmbedding-41da76481ac9-Date-2022-01-07_Time-08-43-40.log ArchR logging to : ArchRLogs/ArchR-plotEmbedding-41da6152092d-Date-2022-01-07_Time-08-43-45.log If there is an issue, please report to github with logFile! Getting UMAP Embedding ColorBy = cellColData Plotting Embedding 1 ArchR logging successful to : ArchRLogs/ArchR-plotEmbedding-41da6152092d-Date-2022-01-07_Time-08-43-45.log
ArchR logging to : ArchRLogs/ArchR-plotEmbedding-41da7510c6f5-Date-2022-01-07_Time-08-43-52.log If there is an issue, please report to github with logFile! Getting UMAP Embedding ColorBy = cellColData Plotting Embedding 1 ArchR logging successful to : ArchRLogs/ArchR-plotEmbedding-41da7510c6f5-Date-2022-01-07_Time-08-43-52.log
## Neuron vs. Glia markers
markerGenes1 <- c('Rbfox3', # Neurons
'Slc17a7', # Excitatory Neurons
'Lhx6', #MGE Interneurons
'Adarb2', #CGE Interneurons
'Aqp4', # Astrocyte
'Cx3cr1', # Microglia
'Pdgfra', #OPC
'Mog', #Oligo
'Cldn5' # Endothelial
)
p <- plotEmbedding( ArchRProj = proj, colorBy = "GeneScoreMatrix",
name = markerGenes1, embedding = "UMAPH200_ATAC")
p <- lapply(p, function(x){
x + guides(color = FALSE, fill = FALSE) +
theme_ArchR(baseSize = 6.5) + theme(plot.margin = unit(c(0, 0, 0, 0), "cm")) +
theme( axis.text.x=element_blank(), axis.ticks.x=element_blank(),
axis.text.y=element_blank(), axis.ticks.y=element_blank())
})
do.call(cowplot::plot_grid, c(list(ncol = 3),p))
Getting ImputeWeights ArchR logging to : ArchRLogs/ArchR-plotEmbedding-41da1f333ef9-Date-2022-01-07_Time-08-43-59.log If there is an issue, please report to github with logFile! Getting UMAP Embedding ColorBy = GeneScoreMatrix Getting Matrix Values... 2022-01-07 08:43:59 : Imputing Matrix Using weights on disk Using weights on disk Plotting Embedding 1 2 3 4 5 6 7 8 9 ArchR logging successful to : ArchRLogs/ArchR-plotEmbedding-41da1f333ef9-Date-2022-01-07_Time-08-43-59.log Warning message: “`guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead.” Warning message: “`guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead.” Warning message: “`guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead.” Warning message: “`guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead.” Warning message: “`guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead.” Warning message: “`guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead.” Warning message: “`guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead.” Warning message: “`guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead.” Warning message: “`guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead.”
## plot Excitatory neuron markers for major class and upper layers
markerGenes1 <- c(
'Rbfox3', 'Slc17a7', 'Gad1', # Main classes
'Cux2', 'Meis2', "Rorb", # L3/ L4 IT
"Alpl", 'Tbx15') # L4/5)
p <- plotEmbedding( ArchRProj = proj, colorBy = "GeneScoreMatrix",
name = markerGenes1, embedding = "UMAPH200_ATAC")
p <- lapply(p, function(x){
x + guides(color = FALSE, fill = FALSE) +
theme_ArchR(baseSize = 6.5) + theme(plot.margin = unit(c(0, 0, 0, 0), "cm")) +
theme( axis.text.x=element_blank(), axis.ticks.x=element_blank(),
axis.text.y=element_blank(), axis.ticks.y=element_blank())
})
do.call(cowplot::plot_grid, c(list(nrow =2),p))
Getting ImputeWeights ArchR logging to : ArchRLogs/ArchR-plotEmbedding-41da7d020b44-Date-2022-01-07_Time-08-45-28.log If there is an issue, please report to github with logFile! Getting UMAP Embedding ColorBy = GeneScoreMatrix Getting Matrix Values... 2022-01-07 08:45:28 : Imputing Matrix Using weights on disk Using weights on disk Plotting Embedding 1 2 3 4 5 6 7 8 ArchR logging successful to : ArchRLogs/ArchR-plotEmbedding-41da7d020b44-Date-2022-01-07_Time-08-45-28.log Warning message: “`guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead.” Warning message: “`guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead.” Warning message: “`guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead.” Warning message: “`guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead.” Warning message: “`guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead.” Warning message: “`guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead.” Warning message: “`guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead.” Warning message: “`guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead.”
## plot Excitatory neuron markers for deeper layers
markerGenes1 <- c(
'Themis', # Car3 and L6 IT
'Pou3f1', 'Pcp4', 'Nr4a2', # L5
'Fezf2', 'Foxp2',# NP and L6, L5 ET
'Syt6', 'Itga8' #L6
)
p <- plotEmbedding( ArchRProj = proj, colorBy = "GeneScoreMatrix",
name = markerGenes1, embedding = "UMAPH200_ATAC")
p <- lapply(p, function(x){
x + guides(color = FALSE, fill = FALSE) +
theme_ArchR(baseSize = 6.5) + theme(plot.margin = unit(c(0, 0, 0, 0), "cm")) +
theme( axis.text.x=element_blank(), axis.ticks.x=element_blank(),
axis.text.y=element_blank(), axis.ticks.y=element_blank())
})
do.call(cowplot::plot_grid, c(list(nrow = 2),p))
Getting ImputeWeights ArchR logging to : ArchRLogs/ArchR-plotEmbedding-41da8282cd6-Date-2022-01-07_Time-08-46-37.log If there is an issue, please report to github with logFile! Getting UMAP Embedding ColorBy = GeneScoreMatrix Getting Matrix Values... 2022-01-07 08:46:38 : Imputing Matrix Using weights on disk Using weights on disk Plotting Embedding 1 2 3 4 5 6 7 8 ArchR logging successful to : ArchRLogs/ArchR-plotEmbedding-41da8282cd6-Date-2022-01-07_Time-08-46-37.log Warning message: “`guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead.” Warning message: “`guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead.” Warning message: “`guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead.” Warning message: “`guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead.” Warning message: “`guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead.” Warning message: “`guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead.” Warning message: “`guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead.” Warning message: “`guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead.”
## plot more interneuron markers
markerGenes1 <- c('Lhx6', "Pvalb", 'TRPS1', 'Sst', # MGE markers
'Adarb2', 'Vip', 'Sncg', 'Lamp5') # CGE markers
p <- plotEmbedding( ArchRProj = proj, colorBy = "GeneScoreMatrix",
name = markerGenes1, embedding = "UMAPH200_ATAC")
p <- lapply(p, function(x){
x + guides(color = FALSE, fill = FALSE) +
theme_ArchR(baseSize = 6.5) + theme(plot.margin = unit(c(0, 0, 0, 0), "cm")) +
theme( axis.text.x=element_blank(), axis.ticks.x=element_blank(),
axis.text.y=element_blank(), axis.ticks.y=element_blank())
})
do.call(cowplot::plot_grid, c(list(nrow = 2),p))
Getting ImputeWeights ArchR logging to : ArchRLogs/ArchR-plotEmbedding-41da307e192b-Date-2022-01-07_Time-08-47-37.log If there is an issue, please report to github with logFile! Getting UMAP Embedding ColorBy = GeneScoreMatrix Getting Matrix Values... 2022-01-07 08:47:37 : Imputing Matrix Using weights on disk Using weights on disk Plotting Embedding 1 2 3 4 5 6 7 8 ArchR logging successful to : ArchRLogs/ArchR-plotEmbedding-41da307e192b-Date-2022-01-07_Time-08-47-37.log Warning message: “`guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead.” Warning message: “`guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead.” Warning message: “`guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead.” Warning message: “`guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead.” Warning message: “`guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead.” Warning message: “`guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead.” Warning message: “`guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead.” Warning message: “`guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead.”
############################################
# using marker gene scores, give cluster names
remapClust <- c(
'C1'='EXC',
'C2'='EXC',
'C3'='EXC',
'C4'='EXC',
'C5'='EXC',
'C6'='EXC',
'C7'='Drop',
'C8'='EXC',
'C9'='Drop',
'C10'='EXC',
'C11'='EXC',
'C12'='EXC',
'C13'='EXC',
'C14'='INH_SST',
'C15'='INH_PVALB',
'C16'='Drop',
'C17'='INH_VIP',
'C18'='INH_LAMP5',
'C19'='Microglia',
'C20'='Astro',
'C21'='Drop',
'C22'='Endo',
'C23'='Oligo',
'C24'='OPC',
'C25'='Drop'
)
proj$Celltype1 <- mapLabels(proj$ClustersH200_ATAC, newLabels = remapClust,
oldLabels = names(remapClust))
table(proj$Celltype1)
Astro Drop Endo EXC INH_LAMP5 INH_PVALB INH_SST INH_VIP
7472 1386 1276 18762 1503 2303 2392 1368
Microglia Oligo OPC
3599 3028 2434
## make UMAP plots
p1 <- plotEmbedding(ArchRProj = proj, colorBy = "cellColData",
name = "Celltype1", embedding = "UMAPH200_ATAC")
p1
ArchR logging to : ArchRLogs/ArchR-plotEmbedding-41da48d2dcff-Date-2022-01-07_Time-10-15-46.log If there is an issue, please report to github with logFile! Getting UMAP Embedding ColorBy = cellColData Plotting Embedding 1 ArchR logging successful to : ArchRLogs/ArchR-plotEmbedding-41da48d2dcff-Date-2022-01-07_Time-10-15-46.log
# drop the drop clusters, pull out the neuron cell types
ARCHDIR2=file.path(PROJDIR,'ArchR_snATAC_DLPFC_neuron')
neuronType = c( 'INH_LAMP5','INH_VIP', 'INH_SST', 'INH_PVALB', 'INH_PVALB','EXC')
idxSample <- BiocGenerics::which(proj$Celltype1 %in% neuronType )
table(proj$Celltype1[idxSample])
cellsSample <- proj$cellNames[idxSample]
proj2 = subsetArchRProject(
ArchRProj = proj, cells = cellsSample,
outputDirectory = ARCHDIR2, force = TRUE
)
EXC INH_LAMP5 INH_PVALB INH_SST INH_VIP
18762 1503 2303 2392 1368
Dropping ImputeWeights Since You Are Subsetting Cells! ImputeWeights is a cell-x-cell Matrix!
Copying ArchRProject to new outputDirectory : /projects/pfenninggroup/singleCell/Macaque_Multiome_DLPFC/data/tidy_data/ArchRProjects/ArchR_snATAC_DLPFC_neuron
Copying Arrow Files...
Getting ImputeWeights
No imputeWeights found, returning NULL
Copying Other Files...
Copying Other Files (1 of 3): Embeddings
Copying Other Files (2 of 3): IterativeLSI150_ATAC
Copying Other Files (3 of 3): IterativeLSI200_ATAC
Saving ArchRProject...
Loading ArchRProject...
Successfully loaded ArchRProject!
/ |
/ \
. / |.
\\\ / |.
\\\ / `|.
\\\ / |.
\ / |\
\\#####\ / ||
==###########> / ||
\\##==......\ / ||
______ = =|__ /__ || \\\
,--' ,----`-,__ ___/' --,-`-===================##========>
\ ' ##_______ _____ ,--,__,=##,__ ///
, __== ___,-,__,--'#' ===' `-' | ##,-/
-,____,---' \\####\\________________,--\\_##,/
___ .______ ______ __ __ .______
/ \ | _ \ / || | | | | _ \
/ ^ \ | |_) | | ,----'| |__| | | |_) |
/ /_\ \ | / | | | __ | | /
/ _____ \ | |\ \\___ | `----.| | | | | |\ \\___.
/__/ \__\ | _| `._____| \______||__| |__| | _| `._____|
# drop the drop clusters, pull out the glia cell types
ARCHDIR2=file.path(PROJDIR,'ArchR_snATAC_DLPFC_glia')
idxSample <- BiocGenerics::which(proj$Celltype1 %ni% c(neuronType, 'Drop'))
table(proj$Celltype1[idxSample])
cellsSample <- proj$cellNames[idxSample]
proj2 = subsetArchRProject(
ArchRProj = proj,
cells = cellsSample,
outputDirectory = ARCHDIR2, force = TRUE
)
Astro Endo Microglia Oligo OPC
7472 1276 3599 3028 2434
Dropping ImputeWeights Since You Are Subsetting Cells! ImputeWeights is a cell-x-cell Matrix!
Copying ArchRProject to new outputDirectory : /projects/pfenninggroup/singleCell/Macaque_Multiome_DLPFC/data/tidy_data/ArchRProjects/ArchR_snATAC_DLPFC_glia
Copying Arrow Files...
Getting ImputeWeights
No imputeWeights found, returning NULL
Copying Other Files...
Copying Other Files (1 of 3): Embeddings
Copying Other Files (2 of 3): IterativeLSI150_ATAC
Copying Other Files (3 of 3): IterativeLSI200_ATAC
Saving ArchRProject...
Loading ArchRProject...
Successfully loaded ArchRProject!
/ |
/ \
. / |.
\\\ / |.
\\\ / `|.
\\\ / |.
\ / |\
\\#####\ / ||
==###########> / ||
\\##==......\ / ||
______ = =|__ /__ || \\\
,--' ,----`-,__ ___/' --,-`-===================##========>
\ ' ##_______ _____ ,--,__,=##,__ ///
, __== ___,-,__,--'#' ===' `-' | ##,-/
-,____,---' \\####\\________________,--\\_##,/
___ .______ ______ __ __ .______
/ \ | _ \ / || | | | | _ \
/ ^ \ | |_) | | ,----'| |__| | | |_) |
/ /_\ \ | / | | | __ | | /
/ _____ \ | |\ \\___ | `----.| | | | | |\ \\___.
/__/ \__\ | _| `._____| \______||__| |__| | _| `._____|
proj = saveArchRProject(ArchRProj = proj)
Saving ArchRProject...
Loading ArchRProject...
Successfully loaded ArchRProject!
/ |
/ \
. / |.
\\\ / |.
\\\ / `|.
\\\ / |.
\ / |\
\\#####\ / ||
==###########> / ||
\\##==......\ / ||
______ = =|__ /__ || \\\
,--' ,----`-,__ ___/' --,-`-===================##========>
\ ' ##_______ _____ ,--,__,=##,__ ///
, __== ___,-,__,--'#' ===' `-' | ##,-/
-,____,---' \\####\\________________,--\\_##,/
___ .______ ______ __ __ .______
/ \ | _ \ / || | | | | _ \
/ ^ \ | |_) | | ,----'| |__| | | |_) |
/ /_\ \ | / | | | __ | | /
/ _____ \ | |\ \\___ | `----.| | | | | |\ \\___.
/__/ \__\ | _| `._____| \______||__| |__| | _| `._____|